package cn.calm.application.action;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.osgi.interceptor.ServiceAware;

import cn.calm.application.service.IApplicationService;
import cn.calm.commons.action.CurdAction;
import cn.calm.commons.entity.PageMode;
import cn.calm.entity.Application;

@SuppressWarnings("rawtypes")
public class ApplicationAction<T extends Application,S extends IApplicationService<T>> extends CurdAction<T,S> implements ServiceAware<IApplicationService>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final Logger logger = Logger
			.getLogger(ApplicationAction.class);

	@Override
	public String getModeName() {
		return "application";
	}
	@Override
	public Map<String, List<String>> getFieldErrors() {
		return super.getFieldErrors();
	}

	@Override
	public Collection<String> getActionErrors() {
		return super.getActionErrors();
	}

	@Override
	public T getT() {
		return super.getT();
	}

	@Override
	public PageMode getPageMode() {
		return super.getPageMode();
	}
	@Override
	public List<T> getList() {
		return super.getList();
	}

	@SuppressWarnings("unchecked")
	@Override
	public Class<T> getEntityClass() {
		return (Class<T>) Application.class;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void setServices(List<IApplicationService> services) {
		if (service == null) {
			if (services != null && services.size() > 0) {
				service = (S) services.get(0);
			}
		}		
	}
}
